<template>
  <div>
    <a-card :bordered="false">
      <f-table ref="table" rowKey="materialPlanId" :scroll="{x:1980,y:columns.length*35}" :columns="newColumns" :exportBtn="false" :multiple="false"  :params="queryParam" :api="api.bmep2" handler="materialPlan200PageListHandler">
      </f-table>
    </a-card>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'bmep200AddDetail',
    components: {
    },
    props: {
      versionId: {
        type: String,
        default: ''
      },
      projectId:{
        type: String,
        default: ''
      }
    },
    data() {
      let me = this
      //操作按钮
      let operator = []
      return {
        api:  Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {
        },
        // 表头
        columns: [
          {
            title: '序号',
            width: 60,
            align: 'center',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '专业代码',
            width: 100,
            align: 'center',
            dataIndex: 'majorCode'
          },
          {
            title: '专业名称',
            width: 100,
            align: 'center',
            dataIndex: 'majorName'
          },
          {
            title: '工程包名称',
            width: 100,
            align: 'center',
            dataIndex: 'packageName'
          },
          {
            title: '工程包代码',
            width: 100,
            align: 'center',
            dataIndex: 'packageNo'
          },
          {
            title: '物料代码',
            width: 100,
            align: 'center',
            dataIndex: 'materialCode'
          },
          {
            title: '物料wbs代码',
            width: 120,
            align: 'center',
            dataIndex: 'materialWbsCode'
          },
          {
            title: '设备、材料名称',
            width: 200,
            align: 'center',
            dataIndex: 'materialName'
          },
          // {
          //   title: '型号/规格',
          //   width: 200,
          //   align: 'center',
          //   dataIndex: 'materiaSpecs'
          // },
          // {
          //   title: '项目名称',
          //   width: 200,
          //   align: 'center',
          //   dataIndex: 'materiaSpecs'
          // },
          // {
          //   title: '技术参数或技术说明',
          //   width: 200,
          //   align: 'center',
          //   dataIndex: 'technicalData'
          // },
          {
            title: '对外合同清单描述',
            width: 200,
            align: 'center',
            dataIndex: 'contractDesc'
          },
          {
            title: '区域',
            width: 100,
            align: 'center',
            dataIndex: 'materialArea'
          },
          // {
          //   title: '系统',
          //   width: '100',
          //   align: 'center',
          //   dataIndex: 'materialUse'
          // },
          {
            title: '层级号',
            width: 100,
            align: 'center',
            dataIndex: 'levelNo'
          },

          {
            title: '计量单位',
            width: 100,
            align: 'center',
            dataIndex: 'measurementUnit'
          },
          {
            title: '换算单位',
            width: 100,
            align: 'center',
            dataIndex: 'conversionUnit'
          },

          // {
          //   title: '100工程量计量单位合计',
          //   width: '220',
          //   align: 'center',
          //   dataIndex: 'unitBillQuantity100'
          // },
          // {
          //   title: '100工程量换算单位合计',
          //   width: '220',
          //   align: 'center',
          //   dataIndex: 'convertBillQuantity100'
          // },
          // {
          //   title: '200工程量计量单位合计',
          //   width: '220',
          //   align: 'center',
          //   dataIndex: 'unitBillQuantity200'
          // },
          // {
          //   title: '200工程量换算单位合计',
          //   width: '220',
          //   align: 'center',
          //   dataIndex: 'convertBillQuantity200'
          // },
          {
            title: '100预算成本工程量',
            width: 150,
            align: 'center',
            dataIndex: 'costQuantity100'
          },
          {
            title: '200预算成本工程量',
            width: 150,
            align: 'center',
            dataIndex: 'costQuantity200'
          },
          {
            title: '损耗',
            width: 100,
            align: 'center',
            dataIndex: 'loss'
          },
          {
            title: '200计划采购量',
            width: 120,
            align: 'center',
            dataIndex: 'planPurchaseCount'
          },
          // {
          //   title: '本次采购量',
          //   width: '30',
          //   align: 'center',
          //   dataIndex: 'purchaseCount'
          // },
          {
            title: '在途',
            width: 80,
            align: 'center',
            dataIndex: 'ztPurchaseCount'
          },
          {
            title: '到货',
            width: 80,
            align: 'center',
            dataIndex: 'dhPurchaseCount'
          },
          {
            title: '计划到货时间',
            width: 100,
            align: 'center',
            dataIndex: 'receivedDate'
          },
          {
            title: '剩余采购量',
            width: 100,
            align: 'center',
            dataIndex: 'planPurchaseCount'
          },
          {
            title: '备注',
            width: 100,
            align: 'center',
            dataIndex: 'remark'
          },
          {
            title: '审批状态',
            width: 100,
            align: 'center',
            dataIndex: 'applayStatus',
            customRender: function (text) {
              return me.columnFormatter(me.api.bmep.applayStatus, text)
            }
          },
          {
            title: '指令号',
            width: 100,
            align: 'center',
            dataIndex: 'instructNumber'
          }
        ],
        newColumns: []
      }
    },
    created() {
     this.initParams()
    },

    methods: {
      initParams () {
        this.projectId = this.$route.query.projectId
        this.column = this.$route.query.columns
        let columnsStr= this.$route.query.columns
        let majorCode = this.$route.query.majorCode
        let packageNo = this.$route.query.packageNo
        // 循环columns 控制显示与隐藏
        let params = {
          projectId: this.projectId,
          planType: 2,
          versionStatus: 0,
          version: '200.01',
          applayStatus: 1,
          majorCode: majorCode,
          packageNo: packageNo
        }
        this.queryParam = params
        if (columnsStr) {
          let newColumns = []
          let queryColumns = columnsStr.split(',')
          this.columns.forEach(column => {
            let dataIndex = column.dataIndex
            queryColumns.forEach(queryColumn => {
              if (dataIndex == queryColumn) {
                newColumns.push(column)
              }
            })
          })
          this.newColumns = newColumns
        } else {
          this.newColumns = this.columns
        }
      }
    }
  }
</script>
